package io.renren.modules.peoplemanage.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.peoplemanage.entity.SysTeacherEntity;
import io.renren.modules.peoplemanage.service.SysTeacherService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 *
 *
 * @author kiven
 * @email 2213593288@qq.com
 * @date 2020-09-04 16:50:44
 */
@RestController
@RequestMapping("/sys/teacher")
public class SysTeacherController {
    @Autowired
    private SysTeacherService sysTeacherService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:systeacher:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysTeacherService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{teacherId}")
    @RequiresPermissions("generator:systeacher:info")
    public R info(@PathVariable("teacherId") Integer teacherId){
		SysTeacherEntity sysTeacher = sysTeacherService.getById(teacherId);

        return R.ok().put("sysTeacher", sysTeacher);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:systeacher:save")
    public R save(@RequestBody SysTeacherEntity sysTeacher){
		sysTeacherService.save(sysTeacher);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:systeacher:update")
    public R update(@RequestBody SysTeacherEntity sysTeacher){
		sysTeacherService.updateById(sysTeacher);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:systeacher:delete")
    public R delete(@RequestBody Integer[] teacherIds){
		sysTeacherService.removeByIds(Arrays.asList(teacherIds));

        return R.ok();
    }

}
